<%@page contentType="text/html;charset=utf-8"%>
<%@include file="../../core/common.jsp"%>
<html>
<head>
<title></title>
</head>
<body>
	<div id="tb" class="toolbar">
		<div style="float: left;">
			<shiro:hasPermission name="param:save">
				<a id="save" class="form-btn success">
					<i class="fa fa-save m-r-5"></i>保存
				</a>
			</shiro:hasPermission>
		</div>
		<div style="float: right;">
			<a id="find" class="form-btn success">
				<i class="fa fa-refresh m-r-5"></i>刷新
			</a>
		</div>
		<div style="clear: both;"></div>
	</div>
	<table id="eg" class="easyui-edatagrid" data-options="url:'${CTX}/mgt/sys/param/find',toolbar:'#tb'">
		<thead>
			<tr>
				<th data-options="field:'name',width:200">参数名称</th>
				<th data-options="field:'value',width:500" editor="{type:'textbox',options:{required:true,validType:'maxLength[500]'}}">参数内容</th>
			</tr>
		</thead>
	</table>
</body>
<script>
	$(function() {
		$('#find').click(function() {
			$('#eg').edatagrid('reload');
		});
		$('#save').click(function() {
			var row = $('#eg').edatagrid('getSelected');
			if (row) {
				var rowIndex = $('#eg').edatagrid('getRowIndex', row);
				if (!$('#eg').edatagrid('validateRow', rowIndex)) {
					return;
				}
				$('#eg').edatagrid('endEdit', rowIndex)
			}
			var data = $('#eg').edatagrid('getChanges', 'updated');
			if (data.length == 0) {
				$.info('请修改数据');
				return;
			}
			$.mask();
			$.ajax({
				url : '${CTX}/mgt/sys/param/save',
				data : {
					json : JSON.stringify(data)
				},
				success : function(data) {
					$.unmask();
					$.handle(data, function() {
						$('#eg').edatagrid('acceptChanges');
					});
				}
			});
		});
	});
</script>
</html>